﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
''' <remarks>控制类</remarks>
<Serializable()> Public Class Control
    Implements ICloneable

    Private m_TitleOne As String = "AermodSystem"
    Private m_TitleTwo As String = ""
    Private m_Run As Boolean = True '是否运行
    Private m_AerageingTime As New AerageingTime '平均时间选项

    Private m_Urbans As New Urbans '城市模型选项
    Private m_AllPolluts As New AllPolluts '所有的污染物
    Private m_Flagpole As New Flagpole '计算点的高度
    Private m_EventProcessing As New EventProcessing
    Private m_Error As New ErrorListing '错误文件



    ''' <remarks>标题1</remarks>
    Public Property TitleOne() As String
        Get
            Return Me.m_TitleOne
        End Get
        Set(ByVal value As String)
            Me.m_TitleOne = value
        End Set
    End Property

    ''' <remarks>标题2</remarks>
    Public Property TitleTwo() As String
        Get
            Return Me.m_TitleTwo
        End Get
        Set(ByVal value As String)
            Me.m_TitleTwo = value
        End Set
    End Property
    ''' <summary>
    ''' 平均时间选项
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property AerageingTime() As AerageingTime
        Get
            Return Me.m_AerageingTime
        End Get
        Set(ByVal value As AerageingTime)
            Me.m_AerageingTime = value
        End Set
    End Property

    ''' <summary>
    ''' 城市模型选项
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Urbans() As Urbans
        Get
            Return Me.m_Urbans
        End Get
        Set(ByVal value As Urbans)
            Me.m_Urbans = value
        End Set
    End Property
    ''' <summary>
    ''' 所有污染物选项
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property AllPolluts() As AllPolluts
        Get
            Return Me.m_AllPolluts
        End Get
        Set(ByVal value As AllPolluts)
            Me.m_AllPolluts = value
        End Set
    End Property
    ''' <summary>
    ''' 计算点高度
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Flagpole() As Flagpole
        Get
            Return Me.m_Flagpole
        End Get
        Set(ByVal value As Flagpole)
            Me.m_Flagpole = value
        End Set
    End Property

    Public Property Run() As Boolean
        Get
            Return Me.m_Run
        End Get
        Set(ByVal value As Boolean)
            Me.m_Run = value
        End Set
    End Property

    Public Property ErrorListing() As ErrorListing
        Get
            Return Me.m_Error
        End Get
        Set(ByVal value As ErrorListing)
            Me.m_Error = value
        End Set
    End Property

    Public Property EventProceessing() As EventProcessing
        Get
            Return Me.m_EventProcessing
        End Get
        Set(ByVal value As EventProcessing)
            Me.m_EventProcessing = value
        End Set
    End Property
    
    Public Function OutPutContol(ByVal index As Integer) As String
        Dim strCo As String = ""
        strCo = "CO STARTING  " & vbCrLf
        '标题1
        If Me.m_TitleOne <> "" Then
            strCo = strCo & "CO TITLEONE  " & Me.m_TitleOne & vbCrLf
        Else
            strCo = strCo & "CO TITLEONE  " & "标题1" & vbCrLf
        End If
        '标题2
        If Me.m_TitleTwo <> "" Then
            strCo = strCo & "CO TITLETWO  " & Me.m_TitleTwo & vbCrLf
        End If

        '污染物选项。包含扩散模型选项和时间选项
        strCo = strCo & Me.m_AllPolluts.OutPutAllSelectedPolluts(index, Me.m_AerageingTime)
        '城市模型选项
        strCo = strCo & Me.m_Urbans.OutPutUrban()
        '计算点高度
        If Me.m_Flagpole.Selected = True Then
            strCo = strCo & "CO FLAGPOLE  " & Me.m_Flagpole.Flagdf & vbCrLf
        End If
        If Me.m_Run = True Then
            strCo = strCo & "CO RUNORNOT  RUN  " & vbCrLf
        Else
            strCo = strCo & "CO RUNORNOT  NOT  " & vbCrLf
        End If
        'Event 文件
        strCo = strCo & Me.m_EventProcessing.OutPutEvent()
        'Error 文件
        strCo = strCo & Me.m_Error.OutPutError()
        '结束
        strCo = strCo & "CO FINISHED" & vbCrLf & vbCrLf
        Return strCo
    End Function

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim objCopy As New Control()
        objCopy.m_TitleOne = Me.m_TitleOne
        objCopy.m_TitleTwo = Me.m_TitleTwo
        objCopy.m_Run = Me.m_Run
        objCopy.m_AerageingTime = Me.m_AerageingTime.Clone '平均时间选项
        objCopy.m_Urbans = Me.m_Urbans.Clone   '城市模型选项
        objCopy.m_AllPolluts = Me.m_AllPolluts.Clone  '所有的污染物
        objCopy.m_Flagpole = Me.m_Flagpole.Clone  '计算点的高度
        objCopy.m_EventProcessing = Me.m_EventProcessing.Clone
        objCopy.m_Error = Me.m_Error.Clone   '错误文件

        Return objCopy
    End Function
    <OnDeserializing()> _
    Friend Sub OnDeserializingMethod(ByVal context As StreamingContext)

    End Sub

    <OnDeserialized()> _
    Friend Sub OnDeserializedMethod(ByVal context As StreamingContext)

    End Sub
End Class
